package javaBean;

import java.lang.reflect.Field;

public class AccessPersonFields {
    public static void main(String[] args) {
        try {
            Class clz = Class.forName("javaBean.Person");
            Object obj = clz.newInstance();
            Field name = clz.getDeclaredField("name");
            name.setAccessible(true);
            System.out.println("赋值前的name:"+name.get(obj));
            name.set(obj,"Now Person");
            System.out.println("赋值后的name:"+name.get(obj));
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
